#!/bin/sh

# ----------------------------------------------------------
# Init Launcher for: Observer Support System Watchdog (OSW).
# ----------------------------------------------------------

. /opt/ngat/etc/bashrc

DAT=`date -u +"%j"`
OSW_CONSOLE_LOG_FILE=${DEPLOY_TMP}/osw_${DEPLOY_SYSTEM}.log

# Source function library.
/etc/rc.d/init.d/functions

case "$1" in
  start)
	echo "Starting Observer Support System Watchdog."
	echo "Logging to: " ${OSW_CONSOLE_LOG_FILE}
	${DEPLOY_BIN}/osw start $DEPLOY_SYSTEM  1>> ${OSW_CONSOLE_LOG_FILE} 2>&1 & 
	;;
  stop)
	echo "Shutting down Observer Support System Watchdog."
	${DEPLOY_BIN}/osw stop $DEPLOY_SYSTEM 1>> ${OSW_CONSOLE_LOG_FILE}_stop 2>&1 &     
	;;
  restart)
	$0 stop
	echo "Restarting in 30 secs" 
	sleep 30
	$0 start
	;;
  *)
	echo "Usage: $0 { start | stop | restart }"
	exit 1
esac

exit 0
